﻿using System;
using System.Configuration;

using SBPweb.Communication.Shared.Library.Contacts;
using SBPweb.Communication.Shared.Library.Connections;

namespace SBPweb.Communication.Client.Library.Xmpp.Connections
{

    public partial class ConnectionManagerConfigurationElement : ConfigurationElement, IConnectionManagerConfiguration
    {

        #region Property accessors

        [ConfigurationProperty("server", IsRequired = true)]
        public string Server
        {
            get
            {
                return (string)this["server"];
            }
        }

        [ConfigurationProperty("port", IsRequired = true)]
        public int Port
        {
            get
            {
                return Convert.ToInt16(this["port"]);
            }
        }

        [ConfigurationProperty("resource", IsRequired = false, DefaultValue = "SBPweb.Communication.Client.Library")]
        public string Resource
        {
            get
            {
                return (string)this["resource"];
            }
        }

        [ConfigurationProperty("isSslNeeded", IsRequired = false, DefaultValue = false)]
        public bool IsSslNeeded
        {
            get
            {
                return Convert.ToBoolean(this["isSslNeeded"]);
            }
        }

        [ConfigurationProperty("isCompressionNeeded", IsRequired = false, DefaultValue = false)]
        public bool IsCompressionNeeded
        {
            get
            {
                return Convert.ToBoolean(this["isCompressionNeeded"]);
            }
        }

        [ConfigurationProperty("sendAvailabilityWhenConnected", IsRequired = false, DefaultValue = false)]
        public bool SendAvailabilityWhenConnected
        {
            get
            {
                return Convert.ToBoolean(this["sendAvailabilityWhenConnected"]);
            }
        }

        [ConfigurationProperty("defaultAvailability", IsRequired = false, DefaultValue = AvailabilityTypes.Available)]
        public AvailabilityTypes DefaultAvailability
        {
            get
            {
                return (AvailabilityTypes)Enum.Parse(typeof(AvailabilityTypes), this["defaultAvailability"].ToString());
            }
        }

        #endregion

    }

}